<?php
//CONFIGURACOES DO SITE ############################################
//AUTOLOAD DE CLASSES ##############################################
//O OPERADOR NEW IRA JOGAR PARA O METODO __AUTOLOAD, O NOME DA CLASSE.
//METODO MAGICO
function __autoload($Class) {
    $dirName = 'class';
    if(file_exists("{$dirName}/{$Class}.php")):
        echo "Tem arquivo "."{$dirName}/{$Class}.php"."<hr>";
        require_once("{$dirName}/{$Class}.php");
    else:
        die("Erro ao incluir "."{$dirName}/{$Class}.php"."<hr>");
    endif;
}

//TRATAMENTO DE ERROS ##############################################
//CSS constantes :: Mensagens de Erro
define('WS_ACCEPT','accept');
define('WS_INFOR','infor');
define('WS_ALERT','alert');
define('WS_ERROR','error');

//WSERRO  :: Exibe erros lancados :: Front
function WSErro($ErrMsg, $ErrNo, $ErrDie = null){
    $CssClass = ($ErrNo == E_USER_NOTICE ? WS_INFOR : ($ErrNo == E_USER_WARNING ? WS_ALERT : ($ErrNo == E_USER_ERROR ? WS_ERROR : $ErrNo)));
    echo "<p class=\"trigger {$CssClass}\">{$ErrMsg}<span class=\"ajax_close\"></span></p>";
   
    if($ErrDie):
        die;
    endif;
}
//PHPErro :: personaliza o gatilho do PHP
function PHPErro($ErrNo, $ErrMsg, $ErrFile, $ErrLine){
     $CssClass = ($ErrNo == E_USER_NOTICE ? WS_INFOR : ($ErrNo == E_USER_WARNING ? WS_ALERT : ($ErrNo == E_USER_ERROR ? WS_ERROR : $ErrNo)));
     echo "<p class=\"trigger {$CssClass}\">";
     echo "<b>Erro na Linha: {$ErrLine} :: </b> {$ErrMsg}<br>";
     echo "<small>{$ErrFile}</small>";
     echo "<span class=\"ajax_close\"></span></p>";
     
     if($ErrNo == E_USER_ERROR):
         die;
     endif;
}

set_error_handler('PHPErro');
